

import pygame

import sys


from pygame.locals import *

bg=(0,0,0)
bg=(220,200,201)

pygame.init()

size = width,height=500,500
screen = pygame.display.set_mode(size, 0)

img = pygame.image.load("g.jpg").convert_alpha()
background = pygame.image.load("abstract-5.jpg").convert()
position=img_rect = img.get_rect()


# print(position)

# 逐个元素，然后不是白色，就设置透明度为200

# for i in range(position.width):
#     for j in range(position.height):
#         temp = img.get_at((i,j))

#         if temp[3]!=0:
#             temp[3]=200
        
#         img.set_at((i,j),temp)


def blit_alpha():
    
    pass

while True:
    
    for e in pygame.event.get():
        
        if e.type == QUIT:
            sys.exit()

    # screen.fill(bg)

    # 只需要他的矩形区域
    temp = pygame.Surface((img.get_width(), img.get_height())).convert()
    # temp.blit(screen,(-100,-100))
    # temp.blit(img,(100,100))
    # temp.set_alpha(200)

    screen.blit(background, (0, 0))
    temp.blit(screen, (-100, -100 ))
    temp.blit(img, (100, 100))
    temp.set_alpha(200)     

    screen.blit(temp, position)

    # temp.blit(background,(-0,-0))
    # temp.blit(img,(100,100))

    # screen.blit(temp,(100,100))
    pygame.display.flip()


